#ifndef GROUND_H
#define GROUND_H
#include "../util/NTuple.h"
#include "../geom/PolyModel.h"
#include "../glutil/ModelRenderer.h"
#include "../glutil/shaderUtils.h"
#include <memory>

/** Draws a slightly elevated ground circle with the assigned texture */
class Ground
{
    private:
        /** Texture to use when drawing the ground */
        unsigned int m_texture1;

        /** Calculates the position of a ground vertex based on several parameters 
            @param radius Circle radius
            @param segments Number of segments in a circle
            @param currentPoint Number of the current point in the circle
            \return Point position
         */
		util::Pair<float> getSegmentedCirclePoint(float radius, int segments, int currentPoint);

        /** Calculates the ground height at a certain distance from the center 
            @param radius Radius of the ground
            @param now Distance to the center of the current point */
        float getGroundCircleHeight(float radius,float now);
		geom::PolyModel m_model;
		glutil::ModelRenderer * m_renderer;
   		glutil::ShaderProgram * m_groundShader; 
    public:
        /** Draws a ground with the specified radius and segmentation
          */
        void drawGroundMound(float radius, int segmentsPerCircle, int circles, float opacity);
        /** Constructor*/
        Ground();

		~Ground();

        /** Sets the ground texture
         @param texture OpenGL texture ID of the texture to use*/
        void setTexture(unsigned int texture){m_texture1 = texture;}

        /** Draws the ground */
        void draw(float opacity);
        /** Deletes all arrays created to draw the ground */
};

#endif

